import { Button, Tooltip, InputNumber } from 'antd';
import { getColorTextLoadMap, onMouseOutBtn, removeDateHmsStr, renderTableText, tableSorter, tooltipLength, priceFormat } from '@/utils';
import { PlusCircleOutlined, DeleteOutlined } from '@ant-design/icons';
import { getLoadMapList, getSelectDataMapList, getTenantID } from '@/utils';
import { ILoadMapTypeAll } from '@/common';
import { findObjectById } from '@/utils/findObjectById';

/** 材料表格 */
const contractModalColumns = (delSelectRow, pageType) => {
  const isDetail: boolean = pageType == 'view'; // 是否是查看
  let tableConfig: Record<string, any>[] = [
    {
      title: '合同编号',
      dataIndex: 'contractCode',
      key: 'contractCode',
      fixed: 'left',
      width: 100,
      sorter: (a: any, b: any) => tableSorter(a, b, 'contractCode'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '合同名称',
      dataIndex: 'contractName',
      key: 'contractName',
      fixed: 'left',
      width: 100,
      sorter: (a: any, b: any) => tableSorter(a, b, 'contractName'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '合同金额',
      dataIndex: 'contractAmt',
      key: 'contractAmt',
      width: 100,
      sorter: (a: any, b: any) => tableSorter(a, b, 'contractAmt'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '资金来源编号',
      dataIndex: 'moneyFromCode',
      key: 'moneyFromCode',
      width: 100,
      sorter: (a: any, b: any) => tableSorter(a, b, 'moneyFromCode'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '资金来源',
      dataIndex: 'moneyFrom',
      key: 'moneyFrom',
      width: 100,
      sorter: (a: any, b: any) => tableSorter(a, b, 'moneyFrom'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '合同签订时间',
      dataIndex: 'signTime',
      key: 'signTime',
      visible: true,
      width: 100,
      sorter: (a: any, b: any) => tableSorter(a, b, 'signTime'),
      render: (text: number | any) => {
        return <span>{text ? text : '--'}</span>;
      },
    },
    {
      title: '采购方式',
      dataIndex: 'applyType',
      key: 'applyType',
      visible: true,
      width: 100,
      sorter: (a: any, b: any) => tableSorter(a, b, 'applyType'),
      render: (text: string) => {
        return <span>{text ? text : '--'}</span>;
      },
    },
  ];
  if (pageType != 'view') {
    tableConfig?.push({
      title: <div style={{ width: '100%', textAlign: 'center' }}>操作</div>,
      dataIndex: 'otherBtn',
      key: 'otherBtn',
      visible: true,
      width: 80,
      fixed: 'right',
      render: (_text: any, record: any) => {
        return (
          <div className="counterpoartDelBtnStyle">
            <Button
              type="link"
              size="small"
              icon={<DeleteOutlined />}
              className={'manageBtntTxtStyle'}
              onMouseOut={onMouseOutBtn}
              onClick={() => delSelectRow(record)}
            >
              取消
            </Button>
          </div>
        );
      },
    });
  }
  return tableConfig;
};

/** 表格配置 */
const contractTableConfig = () => {
  return [
    {
      title: '合同编号',
      dataIndex: 'contractCode',
      key: 'contractCode',
      fixed: 'left',
      width: 100,
      sorter: (a: any, b: any) => tableSorter(a, b, 'contractCode'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '合同名称',
      dataIndex: 'contractName',
      key: 'contractName',
      fixed: 'left',
      width: 100,
      sorter: (a: any, b: any) => tableSorter(a, b, 'contractName'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '合同金额',
      dataIndex: 'sumInTax',
      key: 'sumInTax',
      width: 100,
      sorter: (a: any, b: any) => tableSorter(a, b, 'sumInTax'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '资金来源编号',
      dataIndex: 'projectID',
      key: 'projectID',
      width: 100,
      sorter: (a: any, b: any) => tableSorter(a, b, 'projectID'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '资金来源',
      dataIndex: 'projectName',
      key: 'projectName',
      width: 100,
      sorter: (a: any, b: any) => tableSorter(a, b, 'projectName'),
      render: (text: string) => renderTableText(text, true),
    },
    // {
    //   title: '合同签订时间',
    //   dataIndex: 'signTime',
    //   key: 'signTime',
    //   visible: true,
    //   width: 100,
    //   sorter: (a: any, b: any) => tableSorter(a, b, 'signTime'),
    //   render: (text: number | any) => {
    //     return <span>{text ? text : '--'}</span>;
    //   },
    // },
    {
      title: '采购方式',
      dataIndex: 'procureRealName',
      key: 'procureRealName',
      visible: true,
      width: 100,
      sorter: (a: any, b: any) => tableSorter(a, b, 'procureRealName'),
      render: (text: string) => renderTableText(text, true),
    },
  ];
};

export { contractTableConfig, contractModalColumns };
